import uuid
from dataclasses import dataclass
from typing import Any

import pytest
from sqlalchemy import insert
from sqlalchemy.ext.asyncio import AsyncSession

from recruit.adapter.database.models import User


@dataclass
class UserTest:
    id: uuid.uuid4()
    user_id: str
    username: str


@pytest.fixture
async def create_user(
        get_user: dict[str, Any],
        db_session: AsyncSession
) -> UserTest:
    stmt = insert(User).values(**get_user).returning(User)
    result = (await db_session.execute(stmt)).scalar_one()
    user = UserTest(
        id=result.id,
        user_id=result.user_id,
        username=result.username
    )
    await db_session.commit()
    return user
